package com.wwd.movie.common;

import com.wwd.movie.login.domain.entity.MovieUser;

public class UserContext {

    private static final ThreadLocal<MovieUser> userThreadLocal = new ThreadLocal<>();

    // 设置用户
    public static void setUser(MovieUser user) {
        userThreadLocal.set(user);
    }

    // 获取用户
    public static MovieUser getUser() {
        return userThreadLocal.get();
    }

    // 清理（避免内存泄漏）
    public static void clear() {
        userThreadLocal.remove();
    }
}
